﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharaAnimator : MonoBehaviour
{
    private Animator m_animator;
    private GridMove m_grid_move;
    private bool m_dead;

    // Start is called before the first frame update
    void Start()
    {
        m_animator = GetComponent<Animator>();

        m_grid_move = GetComponent<GridMove>();
        m_dead = false;
    }

    // Update is called once per frame
    void Update()
    {
        Quaternion quaternion = Quaternion.LookRotation(m_grid_move.GetDirection());
        float t = 1.0f - Mathf.Pow(0.75f, Time.deltaTime * 30.0f);
        transform.localRotation = Quaternion.Lerp(transform.localRotation, quaternion, t);

        m_animator.SetBool("is_walking", m_grid_move.Is_Running());
    }

    public void OnDead()
    {
        m_dead = true;
        m_animator.SetTrigger("begin_dead");
        m_animator.SetTrigger("begin_dead_l_arm");
    }
}

